package cn.ekuma.epos.productsfinishing;

import java.util.Properties;

import com.openbravo.bean.ProductCode;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.pos.base.AppLocal;

import cn.ekuma.data.ui.swing.AbstractChildDAOJEditor;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.Dimension;

@SuppressWarnings("serial")
public class ProductCodeEditor extends AbstractChildDAOJEditor<ProductCode,String> {
	private JTextField textField;

	public ProductCodeEditor(DirtyManager dirty) {
		super(dirty);
		setPreferredSize(new Dimension(400, 55));
		initComponents();
		textField.getDocument().addDocumentListener(dirty);
	}
	private void initComponents() {
		setLayout(null);
		
		JLabel label = new JLabel();
		label.setBounds(48, 10, 138, 29);
		label.setText(AppLocal.getIntString("label.prodbarcode"));
		add(label);
		
		textField = new JTextField();
		textField.setBounds(196, 10, 158, 27);
		add(textField);
	}

	@Override
	public void refresh() {
		
	}

	@Override
	public String getTabName() {
		return AppLocal.getIntString("label.multicode");
	}

	@Override
	public ProductCode createNew(Properties prop) {
		return new ProductCode(parentNode.getParentKey().getKey());
	}

	@Override
	public void rebuild(ProductCode obj) throws BasicException {
		obj.setCode(textField.getText());
	}

	@Override
	public void updateUI(boolean editAble, int state) {
		textField.setText(obj.getCode());
		textField.setEditable(editAble);
	}

	@Override
	public Class getEditClass() {
		return ProductCode.class;
	}


	

}
